﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using VanTaiProperty;
namespace VanTaiData
{
    public class TMDoNew_Controller : clsConnect
    {
        private clsConnect cls = new clsConnect();
        #region[GetData]
        public DataTable GetData()
        {
            return cls.BindGridData("sp_TMDoNew_Search");
        }
        public DataTable GetDataDetail(int id)
        {
            return cls.LayDuLieuParameter("sp_TMDoNew_Detail_Edit", "@RowID", id);
        }
        public DataTable GetDataDetailLine(string id)
        {
            return cls.LayDuLieuParameter3("sp_TMDoNewLine_Detail_Edit", "@No_", id);
        }
        public DataTable GetDataDetailLineLog(string id)
        {
            return cls.LayDuLieuParameter3("sp_TMDoNewLine_Log", "@No_", id);
        }
        public DataTable GetDataDetailEdit(int id)
        {
            return cls.LayDuLieuParameter("sp_TMDoNew_Detail_Edit_A", "@RowID", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertTMDoNew(clsTMDoNewProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@No_", data.No_);
            cls.AddParameter("@DocumentNo", data.DocumentNo);
            cls.AddParameter("@CustomerNo", data.CustomerNo);
            cls.AddParameter("@PostingDate", data.PostingDate);
            cls.AddParameter("@DocumentDate", data.DocumentDate);
            cls.AddParameter("@DocumentTime", data.DocumentTime);
            cls.AddParameter("@Receiver", data.Receiver);
            cls.AddParameter("@CarNo", data.CarNo);
            cls.AddParameter("@Driver", data.Driver);
            cls.AddParameter("@SealNo", data.SealNo);
            cls.AddParameter("@Foundation", data.Foundation);
            cls.AddParameter("@FoundationDate", data.FoundationDate);
            cls.AddParameter("@LocationNo", data.LocationNo);
            cls.AddParameter("@Container", data.Container);
            cls.AddParameter("@Ship", data.Ship);
            cls.AddParameter("@Reason", data.Reason);
            cls.AddParameter("@CarryExportType", data.CarryExportType);
            cls.AddParameter("@EmployeeNo", data.EmployeeNo);
            cls.AddParameter("@Status", data.Status);
            cls.AddParameter("@Description", data.Description);
            cls.AddParameter("@UserID", data.UserID);
            cls.ExecuteNonQuery("sp_TMDoNew_Insert");
            return true;
        }
        public bool UpdateTMDoNew(clsTMDoNewProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@RowID", data.RowID);
            cls.AddParameter("@No_", data.No_);
            cls.AddParameter("@DocumentNo", data.DocumentNo);
            cls.AddParameter("@CustomerNo", data.CustomerNo);
            cls.AddParameter("@PostingDate", data.PostingDate);
            cls.AddParameter("@DocumentDate", data.DocumentDate);
            cls.AddParameter("@DocumentTime", data.DocumentTime);
            cls.AddParameter("@Receiver", data.Receiver);
            cls.AddParameter("@CarNo", data.CarNo);
            cls.AddParameter("@Driver", data.Driver);
            cls.AddParameter("@SealNo", data.SealNo);
            cls.AddParameter("@Foundation", data.Foundation);
            cls.AddParameter("@FoundationDate", data.FoundationDate);
            cls.AddParameter("@LocationNo", data.LocationNo);
            cls.AddParameter("@Container", data.Container);
            cls.AddParameter("@Ship", data.Ship);
            cls.AddParameter("@Reason", data.Reason);
            cls.AddParameter("@CarryExportType", data.CarryExportType);
            cls.AddParameter("@EmployeeNo", data.EmployeeNo);
            cls.AddParameter("@Status", data.Status);
            cls.AddParameter("@Description", data.Description);
            cls.AddParameter("@UserID", data.UserID);
            cls.ExecuteNonQuery("sp_TMDoNew_Update");
            return true;
        }
        public bool DeleteTMDoNew(int id)
        {
            cls.Delete("sp_TMDoNew_Delete", "@RowID", id);
            return true;
        }
        #endregion

        #region[Search]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TMDoNew_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}